package com.oss.controller.oss;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.oss.common.BaseResponse;
import com.oss.dto.oss.GetByIdDto;
import com.oss.dto.oss.capitalsummary.CapitalSummaryImportDto;
import com.oss.dto.oss.capitalsummary.PageDto;
import com.oss.service.oss.CapitalSummaryService;
import com.oss.vo.oss.capitalsummary.CapitalSummaryAndInOutDetailVO;
import com.oss.vo.oss.capitalsummary.CapitalSummaryOrgDataVO;
import com.oss.vo.oss.capitalsummary.CapitalSummaryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 资金汇总
 */
@RestController
@RequestMapping("/capitalSummary")
public class CapitalSummaryController {
    @Autowired
    CapitalSummaryService capitalSummaryService;

    /**
     * 资金原始数据
     * @param dto
     * @return
     */
    @PostMapping("/selectByPageOrgData")
    public BaseResponse<IPage<CapitalSummaryOrgDataVO>> selectByPageOrgData(@RequestBody @Valid PageDto dto){
        return BaseResponse.success(capitalSummaryService.selectByPageOrgData(dto));
    }

    /**
     * 资金汇总
     * @param dto
     * @return
     */
    @PostMapping("/capitalSummary")
    public BaseResponse<List<CapitalSummaryVO>> capitalSummary(@RequestBody @Valid PageDto dto){
        return BaseResponse.success(capitalSummaryService.capitalSummary(dto));
    }
    @PostMapping("/getById")
    public BaseResponse<CapitalSummaryAndInOutDetailVO> getDetailById(@RequestBody @Valid GetByIdDto dto){
        return BaseResponse.success(capitalSummaryService.getDetailById(dto.getId()));
    }
    @PostMapping("/import")
    public BaseResponse<String> importData(@RequestBody @Valid CapitalSummaryImportDto dto){
        return BaseResponse.success(capitalSummaryService.importData(dto));
    }
}